<?php

$title = $_POST['title'];
$label = $_POST['label'];
$type = $_POST['type'];
$describe = $_POST['describe'];
$content=$_POST['content'];
$time=time();

if($type=='图片'){
    $type1=1;
} else if($type=='文字'){
    $type1=2;
}else if($type=='视频'){
    $type1=3;
};

$sql = mysqli_connect('localhost', 'wd', '123456', 'wd');
//判断是否连接mysql
 if (!$sql) {
      die("连接数据失败！");
    }
    $stmt = mysqli_prepare($sql, "insert into article(`title`,`label`,`describe`,`type`,`content`,`issuetime`)values(?,?,?,?,?,?)");
//(变量,'列名有几个写几个',变量,变量)

mysqli_stmt_bind_param($stmt, 'sssisi', $title,$label,$describe,$type1,$content,$time);
//执行语句

if (mysqli_stmt_execute($stmt)) {
        echo "添加成功！";
    }else{
        echo "添加失败！";
    }
//关闭数据库连接
mysqli_close($sql);
